{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import time as tm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "AppCbk_c = open(\"AppCbk.c\",\"w\")\n",
    "AppCbk_h = open(\"AppCbk_config.h\",\"w\")\n",
    "\n",
    "pd_AppCbk = pd.read_excel(\"AppCbk.xlsx\", 'Sheet1')\n",
    "pd_AppCbkName = pd_AppCbk['function Name']\n",
    "pd_AppCbkEnum = pd_AppCbk['enum']\n",
    "pd_AppCbkfq =  pd_AppCbk['FQ']\n",
    "\n",
    "# generate  .h file\n",
    "print(\"/***********************************************************************\", file=AppCbk_h)\n",
    "print(\"Department : IDA-SW2\", file=AppCbk_h)\n",
    "print(\"Time :\" + tm.strftime('%Y-%m-%d %H:%M:%S',tm.localtime(tm.time())) , file=AppCbk_h)\n",
    "print(\"************************************************************************\", file=AppCbk_h)\n",
    "print(\"* Object        : AppCbk.h\",file=AppCbk_h)\n",
    "print(\"* Module        : Notification callBack\",file=AppCbk_h)\n",
    "print(\"* Instance      : \",file=AppCbk_h)\n",
    "print(\"* Description   : Notification functions\",file=AppCbk_h)\n",
    "print(\"*-----------------------------------------------------------------------*/\",file=AppCbk_h)\n",
    "print(\"\",file=AppCbk_h)\n",
    "print(\"/*=====================Includes=======================================*/\",file=AppCbk_h)\n",
    "print(\"#include <AppCbk_config.h> \", file=AppCbk_c)\n",
    "print(\"\",file=AppCbk_h)\n",
    "print(\"/*=====================Macros=========================================*/\",file=AppCbk_h)\n",
    "print(\"\",file=AppCbk_h)\n",
    "print(\"/*=====================Local Variables================================*/\",file=AppCbk_h)\n",
    "AppCbkEnum_row = 0\n",
    "print(\"typedef enum {\", file=AppCbk_h)\n",
    "while(pd_AppCbkEnum.at[AppCbkEnum_row] != 'end'):\n",
    "    if(pd_AppCbkEnum.at[AppCbkEnum_row] == \" \"):\n",
    "        break\n",
    "    print(pd_AppCbkEnum.at[AppCbkEnum_row] + \" = \" + str(AppCbkEnum_row) +',' , file=AppCbk_h)\n",
    "    AppCbkEnum_row = AppCbkEnum_row + 1\n",
    "print(\"Signal_ALL,\", file=AppCbk_h)\n",
    "print(\"}AppCbk_SignalName_t;\", file=AppCbk_h) \n",
    "AppCbk_h.close()\n",
    "\n",
    "# generate  .C file\n",
    "print(\"/***********************************************************************\", file=AppCbk_c)\n",
    "print(\"Department : IDA-SW2\", file=AppCbk_c)\n",
    "print(\"Time :\" + tm.strftime('%Y-%m-%d %H:%M:%S',tm.localtime(tm.time())) , file=AppCbk_c)\n",
    "print(\"************************************************************************\", file=AppCbk_c)\n",
    "print(\"* Object        : AppCbk.c\",file=AppCbk_c)\n",
    "print(\"* Module        : Notification callBack\",file=AppCbk_c)\n",
    "print(\"* Instance      : \",file=AppCbk_c)\n",
    "print(\"* Description   : Notification functions\",file=AppCbk_c)\n",
    "print(\"*-----------------------------------------------------------------------*/\",file=AppCbk_c)\n",
    "print(\"\",file=AppCbk_c)\n",
    "print(\"/*=====================Includes=======================================*/\",file=AppCbk_c)\n",
    "print(\"#include <AppCbk_config.h> \", file=AppCbk_c)\n",
    "print(\"\",file=AppCbk_c)\n",
    "print(\"/*=====================Macros=========================================*/\",file=AppCbk_c)\n",
    "print(\"\",file=AppCbk_c)\n",
    "print(\"/*=====================Local Variables================================*/\",file=AppCbk_c)\n",
    "# print(\"uint8_t AppCbk_TimeOut[\" + str(AppCbkEnum_row) + \"]\",file=AppCbk_c)\n",
    "print(\"uint8_t AppCbk_TimeOut[ Signal_ALL ];\",file=AppCbk_c)\n",
    "\n",
    "AppCbkName_row = 0\n",
    "\n",
    "\n",
    "while(pd_AppCbkName.at[AppCbkName_row] != 'end'):\n",
    "    if(pd_AppCbkName.at[AppCbkName_row] == \" \"):\n",
    "        break\n",
    "    function_name = \"void\"+ ' ' + \"AppCbk_\" + pd_AppCbkName.at[AppCbkName_row] + \"()\"\n",
    "    print(\"/***********************************************************************\",file=AppCbk_c)\n",
    "    print(\"* FUNCTION    :\" + function_name, file=AppCbk_c)\n",
    "    print(\"* DESCRIPTION :\" + pd_AppCbkName.at[AppCbkName_row] + \" time out notification\" ,file=AppCbk_c)\n",
    "    print(\"* INPUTS      : void\", file=AppCbk_c)\n",
    "    print(\"* RETURN      : void\", file=AppCbk_c)\n",
    "    print(\"***********************************************************************/\",file=AppCbk_c)\n",
    "    print(function_name, file = AppCbk_c)\n",
    "    print(\"{\", file = AppCbk_c)\n",
    "    print(\"\\t\" + \"AppCbk_TimeOut[\" + pd_AppCbkEnum.at[AppCbkName_row] + '] = true',file=AppCbk_c)\n",
    "    print(\"}\", file = AppCbk_c)\n",
    "    print(\"\",file=AppCbk_c)\n",
    "    AppCbkName_row = AppCbkName_row + 1\n",
    "AppCbk_c.close()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
